package com.asl.website.advantage.domain;

import com.asl.common.utils.StringUtils;
import com.asl.website.common.Language;
import com.asl.website.serviceContent.domain.SysServiceContent;

/**
 * @author 482944566@qq.com
 * @version 1.0
 * @date 2025-05-22
 */

public class AdvantageContentDTO {
    private Long advantageId;
    private String title;
    private String advantage;
    private String advantageImg;
    private Integer typeId;
    private Integer sortOrder;
    private String language;

    public AdvantageContentDTO(SysAdvantage entity, String language) {
        this.advantageId = entity.getAdvantageId();
        this.advantageImg = entity.getAdvantageImg();
        this.sortOrder = entity.getSortOrder();
        this.typeId = entity.getTypeId();
        this.language = language;

        switch (Language.fromCode(language)) {
            case EN_US:
                this.title = StringUtils.firstNonBlank(entity.getAdvantageTitleEn(), entity.getAdvantageTitleZh());
                this.advantage = StringUtils.firstNonBlank(entity.getAdvantageDescEn(), entity.getAdvantageDescZh());
                break;
            case DE_DE:
                this.title = StringUtils.firstNonBlank(entity.getAdvantageTitleDe(), entity.getAdvantageTitleZh());
                this.advantage = StringUtils.firstNonBlank(entity.getAdvantageDescDe(), entity.getAdvantageDescZh());
                break;
            default: // 默认中文
                this.title = entity.getAdvantageTitleZh();
                this.advantage = entity.getAdvantageDescZh();
        }
    }

    public Integer getTypeId() {
        return typeId;
    }

    // getters
    public Long getContentId() {
        return advantageId;
    }

    public String getTitle() {
        return title;
    }

    public String getContent() {
        return advantage;
    }

    public String getItemIcon() {
        return advantageImg;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }


    public String getLanguage() {
        return language;
    }
}
